package com.zr.controller.base;

import java.util.List;
import com.zr.utils.AjaxResult;
import javax.annotation.Resource;
import com.zr.vo.base.BaseCustomer;
import com.zr.service.base.BaseCustomerService;
import org.springframework.web.bind.annotation.*;

/**
 * 委托客户增删改查
 */
@RestController
@RequestMapping("/base/customer")
public class BaseCustomerController {

    @Resource
    private BaseCustomerService baseCustomerService;

    /**
     * 条件查询委托客户信息列表
     * @param baseCustomer
     * @return
     * @author liutienan
     */
    @PostMapping("/getList")
    public AjaxResult getList(@RequestBody BaseCustomer baseCustomer){
        return AjaxResult.success(200,"查询成功",baseCustomerService.getList(baseCustomer));
    }

    /**
     * 查询所有委托客户信息列表
     * @return
     * @author liutienan
     */
    @RequestMapping("/listAll")
    public AjaxResult listAll(){
        List<BaseCustomer> baseCustomerList = baseCustomerService.listAll();
        return AjaxResult.success(200, "查询成功", baseCustomerList);
    }

    /**
     * 新增委托用户
     * @param baseCustomer
     * @return
     * @author liutienan
     */
    @RequestMapping("/add")
    public AjaxResult add(@RequestBody BaseCustomer baseCustomer){
        baseCustomerService.add(baseCustomer);
        return AjaxResult.success(200, "新增成功", null);
    }

    /**
     * 修改委托用户
     * @param baseCustomer
     * @return
     * @author liutienan
     */
    @RequestMapping("/edit")
    public AjaxResult edit(@RequestBody BaseCustomer baseCustomer){
        baseCustomerService.edit(baseCustomer);
        return AjaxResult.success(200, "修改成功", null);
    }

    /**
     * 删除委托用户
     * @param id
     * @return
     * @author liutienan
     */
    @RequestMapping("/remove/{id}")
    public AjaxResult remove(@PathVariable("id") Integer id) {
        baseCustomerService.remove(id);
        return AjaxResult.success(200, "删除成功", null);
    }
}
